﻿<UserControl
    x:Class="WinRTXamlToolkit.Debugging.Views.DebugConsoleView"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:WinRTXamlToolkit.Debugging.Views"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:controls="using:WinRTXamlToolkit.Controls"
    xmlns:converters="using:WinRTXamlToolkit.Converters"
    xmlns:views="using:WinRTXamlToolkit.Debugging.Shared.Views"
    xmlns:common="using:WinRTXamlToolkit.Common"
    mc:Ignorable="d"
    d:DesignHeight="300"
    d:DesignWidth="400"
    IsTabStop="False">

    <UserControl.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary
                    Source="ms-appx:///WinRTXamlToolkit.Debugging/Themes/SharedResources.xaml" />
            </ResourceDictionary.MergedDictionaries>
            <converters:NullableBoolToBoolConverter
                x:Key="NullableBoolToBoolConverter" />
        </ResourceDictionary>
    </UserControl.Resources>
    <Grid
        x:Name="LayoutGrid">
        <Grid>
            <!--Wrapping this ToolWindow in a Grid for now to avoid having its ZIndex eclipse everything else.-->
            <controls:ToolWindow
                x:Name="Window"
                Width="800"
                Height="500"
                MinWidth="200"
                MinHeight="100"
                Closing="Window_OnClosing"
                WindowStartupLocation="CenterOwner"
                Opacity="{Binding Opacity}"
                Title="WinRT XAML Toolkit Debug Console">
                <Grid
                    x:Name="MainDebuggingGrid">
                    <Grid.RowDefinitions>
                        <RowDefinition
                            Height="Auto" />
                        <RowDefinition />
                    </Grid.RowDefinitions>
                    <StackPanel
                        x:Name="TabButtonsPanel"
                        Orientation="Horizontal"
                        VerticalAlignment="Bottom"
                        Margin="10,0,0,0">
                        <RadioButton
                            x:Name="LogTabButton"
                            Content="Log"
                            Style="{StaticResource TabButtonStyle}"
                            IsChecked="True" />
                        <RadioButton
                            x:Name="VisualTreeButton"
                            Content="Visual Tree"
                            Style="{StaticResource TabButtonStyle}"
                            IsChecked="{Binding VisualTreeView.IsShown, Mode=TwoWay}" />
                        <!--<Slider
                        x:Name="OpacitySlider"
                        Width="300"
                        Minimum="0.1"
                        Maximum="1"
                        StepFrequency="0.001"
                        Margin="40,16,10,0"
                        Value="{Binding Opacity, Mode=TwoWay}" />-->
                    </StackPanel>

                    <TextBox
                        x:Name="DebugTextBox"
                        Grid.Row="1"
                        Visibility="{Binding VisualTreeView.IsShown, Converter={StaticResource BooleanToInvisibilityConverter}}"
                        Foreground="{StaticResource ApplicationForegroundThemeBrush}"
                        BorderThickness="0"
                        TextWrapping="Wrap"
                        HorizontalAlignment="Stretch"
                        VerticalAlignment="Stretch"
                        ScrollViewer.VerticalScrollBarVisibility="Auto"
                        ScrollViewer.VerticalScrollMode="Auto"
                        IsReadOnly="True" />
                    <local:VisualTreeView
                        x:Name="VisualTreeViewControl"
                        Grid.Row="1"
                        DataContext="{Binding VisualTreeView}"
                        Visibility="{Binding IsShown, Converter={StaticResource BooleanToVisibilityConverter}}"
                        Margin="0" />
                </Grid>
            </controls:ToolWindow>
        </Grid>
        <ItemsControl
            x:Name="Windows"
            IsTabStop="False"
            ItemsSource="{Binding ToolWindows}">
            <ItemsControl.ItemsPanel>
                <ItemsPanelTemplate>
                    <Grid />
                </ItemsPanelTemplate>
            </ItemsControl.ItemsPanel>
            <ItemsControl.ItemTemplateSelector>
                <common:ImplicitDataTemplateSelector>
                    <DataTemplate
                        x:Key="ElementListToolWindowViewModel">
                        <views:ElementListWindow />
                    </DataTemplate>
                    <DataTemplate
                        x:Key="FocusTrackerToolWindowViewModel">
                        <views:FocusTrackerWindow />
                    </DataTemplate>
                </common:ImplicitDataTemplateSelector>
            </ItemsControl.ItemTemplateSelector>
        </ItemsControl>
        <views:HighlightOverlay
            x:Name="HighlightOverlay"
            VerticalAlignment="Stretch"
            HorizontalAlignment="Stretch"
            Visibility="{Binding VisualTreeView.HighlightVisibility}"
            HighlightBounds="{Binding VisualTreeView.HighlightMargin}"
            HighlightText="{Binding VisualTreeView.HighlightText}" />
    </Grid>
</UserControl>
